#include<bits/stdc++.h>
using namespace std;
const int N=1e5+7,M=1e6+7;
int T,n,m,L,V;
struct Speed{
    int id,v,a;
}c[N];
struct hanbaobisheng{
    int x,y;
}b[N];
int p[N],l[N],r[N],w[M];
int h[M];
bool cmp(hanbaobisheng ll,hanbaobisheng rr) {
    if(ll.x==rr.x) return ll.y<rr.y;
    return ll.x<rr.x;
}
int main() {
    freopen("detect.in","r",stdin);
    freopen("detect.out","w",stdout);
    scanf("%d",&T);
    while(T--) {
        memset(h,0,sizeof h);
        scanf("%d%d%d%d",&n,&m,&L,&V);
        for(int i=1;i<=n;++i) scanf("%d%d%d",&c[i].id,&c[i].v,&c[i].a);
        for(int i=1;i<=m;++i) {
            scanf("%d",&p[i]);
            w[p[i]]=i;
        }
        int u=1,ans=0;
        for(int i=0;i<=L;++i) {
            if(i>p[u]) u++;
            h[i]=u;
        }
        for(int i=1;i<=n;++i) {
            l[i]=r[i]=0;
            if(c[i].a==0) {
                if(c[i].v>V) {
                    if(h[c[i].id]<=m){
                        l[i]=p[h[c[i].id]],r[i]=p[m];
                        ans++;
                    }
                }

            }
            else if(c[i].a<0) {
                c[i].a=-c[i].a;
                if(c[i].v>V) {
                    int _v=c[i].v*c[i].v-V*V,_a=2*c[i].a;
                    int k=_v/_a;
                    if(_v%_a) k++;
                    if(c[i].id+k>L) {
                        if(h[c[i].id]<=m){
                            l[i]=p[h[c[i].id]],r[i]=p[m];
                            ans++;
                        }
                    }
                    else if(c[i].id+k>p[h[c[i].id]]) {
                        if(h[c[i].id]<=m){
                            l[i]=p[h[c[i].id]];
                            if(h[c[i].id+k]<=m) r[i]=p[h[c[i].id+k]-1];
                            else r[i]=p[m];
                            //if(l[i]>r[i]) cout<<"!!:"<<h[c[i].id]<<' '<<h[c[i].id]+k<<' '<<m<<":!!"<<endl;;
                            ans++;
                        }
                    }
                }
            }
            else {
                if(c[i].v>V) {
                    if(h[c[i].id]<=m){
                        l[i]=p[h[c[i].id]],r[i]=p[m];
                        ans++;
                    }
                }
                else {
                    int _v=V*V-c[i].v*c[i].v,_a=2*c[i].a;
                    int k=_v/_a+1;
                    if(h[c[i].id]<=m){
                        if(c[i].id+k>=L||h[c[i].id+k]>m) ;
                        else {
                            l[i]=p[h[c[i].id+k]],r[i]=p[m];
                            ans++;
                        }
                    }
                }
            }
        }
        int nn=0;
        for(int i=1;i<=n;++i) {
            if(!l[i]&&!r[i]) continue;
            b[++nn].x=w[l[i]],b[nn].y=w[r[i]];
        }
        sort(b+1,b+nn+1,cmp);
        //cout<<T<<':'<<endl;
        //for(int i=1;i<=nn;++i) cout<<b[i].x<<' '<<b[i].y<<endl;
        int pre=b[1].y,cnt=1;
        for(int i=2;i<=nn;++i) {
            if(b[i].x>pre) {
                cnt++;
                pre=b[i].y;
            }
            pre=min(pre,b[i].y);
        }
        if(ans==0) printf("%d %d\n",ans,m);
        else printf("%d %d\n",ans,m-cnt);
    }
    return 0;
}
